from POP.FileLoader import FileLoader
from typing import Set, List, Tuple, Dict
from tqdm import tqdm
import pickle


class Trainer:
    def __init__(self, hyper_params):
        self.file_loader = FileLoader(hyper_params)

        self.cal_popularity()

    def cal_popularity(self):
        print('POP: Trainer: Calculating popularity...')

        self.popularity = {}

        for _, history in self.file_loader.intereaction_list.items():
            for interact in history:
                if interact.item_id not in self.popularity:
                    self.popularity[interact.item_id] = 0

                self.popularity[interact.item_id] += 1

        print('POP: Trainer: Calculating popularity finished.')


if __name__ == '__main__':
    hyper_params = {
        'dataset_path': '../datasets/lib.txt'
    }

    trainer = Trainer(hyper_params)
